﻿function __getCategory(category){
	      var categoryValue=new Array();
        for (var one in allDic){                          
             if (one==category) return allDic[one];
        }
        return categoryValue;
   }
   
/**
 * 根据ID 数组 来取数据
 * @param {} category
 * @param {} ids
 * @return {}
 */
 function __getCategroyByIds(category, ids) {
	var data = [];
	for (var onec in allDic) {
		if (onec == category) {
			for (var one in allDic[onec]) {
				try {
					if (ids instanceof Array) { // 如果传的是数组
						for (id in ids) {
							if (allDic[onec][one].id == ids[id]) {
							    //console.log('ids:'+allDic[onec][one].id);
								data.push(allDic[onec][one]);
							}
						}
					} else if (typeof ids ==='string' ) { // 字符串
						var idArr = ids.split(',');
						if (idArr.length > 0) { // 如果数组的长度大于1
							for (id in idArr) {
								if (allDic[onec][one].id == id) {
									//console.log('id:'+allDic[onec][one].id);
									//console.log('id:'+allDic[onec][one]);
									data.push(allDic[onec][one]);
								}
							}
						} 
					}
				} catch (e) {
				}
			}
		}
	}
	return data;

}
function __getCategroyCodeValue(category,code){	 
        for (var onec in allDic){        	   
        	   if (onec==category){        	   	
                  for (var one in allDic[onec]){
                  	try{
                  	  if (allDic[onec][one].id==code) return allDic[onec][one].codeNameCn;
                    }catch(e){}
                  }		   	  
        	   }             
        }
        return code;
   }
function __getCategroyCode(category,code){	 
        for (var onec in allDic){        	   
        	   if (onec==category){        	   	
                  for (var one in allDic[onec]){
                  	try{
                  	  if (allDic[onec][one].id==code) return allDic[onec][one];
                    }catch(e){}
                  }		   	  
        	   }             
        }
   }   
function __getCategroyCodeEnValue(category,code){
	      
        for (var onec in allDic){
        	           
        	   if (onec==category){
        	         
                  for (var one in allDic[onec]){
                    try{
                  	  if (allDic[onec][one].id==code) return allDic[onec][one].codeNameEn;
                  	}catch(e){}  
                }		   	  
        	   }             
        }
        return code;
   }
  function __getCategroyCodeValues(category,codes){
  	   if(codes==null) return codes;    
       return __getCategroyCodeValuesBySplit(category,codes+'',',');
  }
  function __getCategroyCodeValuesBySplit(category,codes,split){
       var splitcodes=codes.split(split);
       var values;
       for (i=0;i<splitcodes.length;i++){
       	   try{
       	   	 if (splitcodes[i]==''||splitcodes[i]==null) continue;
             if (i>0)
               values=values+split+__getCategroyCodeValue(category,splitcodes[i]);  
             else values=__getCategroyCodeValue(category,splitcodes[i]);  
          }catch(e){}
       }
       return values
  }
  function __arraysearch(arr,v){
     if (!arr) return false;
     for (i = 0; i < arr.length; i++){
        if (arr[i]==v) return true;
     }
     return false;
  }
  function __getCategoryByParant(category,parent){
  	   parentstr=parent+"";
  	   var arryparent=parentstr.split(',');
  	   var dicCodes=new Array();
        for (var onec in allDic){                          
             if (onec==category) {
             	//return allDic[one];
             	   
             	   for (var one in allDic[onec]){
                  	try{                  		
                  	  //if (allDic[onec][one].parentId==parent){
                      if (__arraysearch(arryparent,allDic[onec][one].parentId)){
                  	  	 //return allDic[onec][one].codeNameCn;
                  	  	 dicCodes[dicCodes.length]=allDic[onec][one];
                  	  } 
                    }catch(e){}
                }
                if (dicCodes.length>0)return dicCodes;
             }	
        }
        //没有则返回父类        
        dicCodes[dicCodes.length]=__getCategroyCode(category,parent);
        return dicCodes;
   }
    
   function __getCategoryCodeParant(category,codes){
   	    var arraycodes=codes.split(',');
   	    var code=codes;
            var arrayObj = new Array();
   	    if (arraycodes.length>0) code=arraycodes[0];//取第一个
   	    for (var onec in allDic){                          
             if (onec==category) {
             	   for (var one in allDic[onec]){
                  	try{
                  	  //if (allDic[onec][one].id==code&&allDic[onec][one].parentId!='0') return allDic[onec][one].parentId;
                  	  if (__arraysearch(arraycodes,allDic[onec][one].id)&&allDic[onec][one].parentId!='0'){
                             if (!__arraysearch(arrayObj,allDic[onec][one].parentId))
                                arrayObj.push(allDic[onec][one].parentId)
                          }
                          
                    }catch(e){}
                 }
             }	
        }
        if (arrayObj.length>0) return arrayObj.toString();
        return code;     	
   }	
   var contactTypeDic = [['电话','D'],['手机','M'],['QQ','Q'],['MSN','S'],['email','E']];
   
   var marriedTypeDic = [['单身',1],['已婚无孩',2],['已婚有孩',3]];
   
   var cvTypeDic = [['BD联系人','1'],['合作决策人','2'],['职位联系人','3'],['收款联系人','4'],['成功候选人','5'],['普通候选人','6']];